package com.ttuproject.ttu.advice;


import com.ttuproject.ttu.exception.Advice;
import lombok.Getter;

/**
 * @Description: <br>
 * @CreateDate: Created in 2020/6/12 13:03 <br>
 * @Author: admin
 */

/*
// 通过这个注解排除为null的属性值
@JsonInclude(JsonInclude.Include.NON_EMPTY)
*/
public class ResponseEnvelope<T> {
    @Getter
    private final Integer code;
    @Getter
    private final String message;
    @Getter
    private T data;

    public ResponseEnvelope(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResponseEnvelope(Advice advice) {
        this.code = advice.getCode();
        this.message = advice.getMsg();
    }

    public ResponseEnvelope(Advice advice, T data) {
        this.code = advice.getCode();
        this.message = advice.getMsg();
        this.data = data;
    }
}